home *** CD-ROM | disk | FTP | other *** search
- Path: web.cae.ca!usenet
- From: fraserh@cae.ca (Fraser Hutchinson)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ gurus, I have a question for you!
- Date: 29 Feb 1996 18:40:37 GMT
- Organization: CAE Electronics Ltd.
- Message-ID: <4h4rv5$mct@web.cae.ca>
- References: <31281804.687F@iglou.com>
- NNTP-Posting-Host: pch63.cae.ca
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In article <31281804.687F@iglou.com>, panther@iglou.com says...
- >
- >How is it possible to check if a variable has been
- >initialized yet? If I do 'if ( !a ) { int a = 1 }' I get
- ^^^
- You cannot check the value of an undeclared variable, and if you
- previously declared a, you cannot redeclare it again like this.
-
- >an error message. Please, any help would be great. Reply
- >to the group or in mail. Thanks in advance!
- >
- >Abe L. Getchell
-
-
- However, this *should* work (I haven't verified it....
-
- int a;
-
- if(!a)
- int a = 1;
-
- which declares a new integer a whose scope and lifetime is the duration
- of the if statement.
-
- So, given this, I would suspect that you did not declare a before eval'ing
- it above.
-
-
- ciao,
-
- Fraser
-
-